<?php
// 本类由系统自动生成，仅供测试用途
class GroupAction extends HomeAction {
//     function _initialize(){
//         if($_GET['gid']){
//             
//            $group=M('Groups');//group_sort'
//            $data['gid']=$_GET['gid'];
//            $group=$group->where($data)->find();
//            //dump($group);
//            $this->assign('Group',$group);
//            //查询关键字
//            $keydata['main_id']=$data['gid'];
//            $keydata['type']='groups';
//            $keyword=D('KeywordView');
//            $keylist=$keyword->where($keydata)->field('id,key_name,key_count')->select();
//            
//         }
//       //  dump($group);
//         $this->assign('mainkey_list',$keylist);
//          //dump($keylist);
//         $this->assign('gid',$_GET['gid']);
//     }
      public function Share_Article(){
        $share=M('Article');
        $data['group_id']=$_GET['gid'];
        $data=$share->where($data)->field('aid,uid,group_id,create_time,uname,name,content,group_name,use_count,useless_count,state')->order('aid desc')->select();
        // dump($data);
        $this->assign('article_list',$data);
        $this->display('share_article');
    }
  
    public  function article(){
        //单个文章主体显示
        $article=M('Article');
        //单个文章评论显示
        $aid=$_GET['aid'];
        $art_list=$article->where(array('aid'=>$aid))->find();
        $this->assign('art_list',$art_list);
        //查询关键字
        $keyword=D('KeywordView');
        $keydata['main_id']=$aid;
         $keydata['type']='article';
        $keylist=$keyword->where($keydata)->field('main_id,id,key_name,key_count')->select();
         $this->assign('key_list',$keylist);
         
         $this->article_comment($aid);
         
       $this->display('article');
    }
    public  function  article_comment($aid){
       
    //article_cid 	article_id 	user_id 	user_name 	comment_date 	
    //comment_content 	comment_type 	comment_parent   
        $comment=D('CommentView');
        
       $data['article_id']=$aid;
       // $data['parent_id']=0;
        
        $commentlist=$comment->where($data)->select();
       // dump($commentlist);
        $this->assign('commentlist',$commentlist);
    }
      public  function  comment_insert($aid){
          $comment=D('comment');
          if($data=$comment->create()){
              $data['comment_date']=date('Y-m-d H:i:m',time());
              $comment->add($data);
              $this->success('成功');
          }else{
              $this->error($comment->getError());
          }
              
      }
      /*已废除*/
    public function group_collects(){
        
         $collect=M('Collect');
         $data['cid']=$_GET['cid'];
         $collect_list=$collect->where($data)->find();
        //dump($collect_list);
         $this->assign('collect',$collect_list);
         $Deliver_collect=D('Deliver_collectView');
         //$data['gid']=$_GET['gid'];aid 	uid 	group_id 群id	uname 用户名	create_time 	name 文章名字	content 
         //	link 原链接	group_name 群名字	use_count 	useless_count 	type 原创,转载	parent_id 原文章id	state
         $cdata['for_id']=$_GET['cid'];
         $cdata['kind']='keyword';
         $collectlist=$Deliver_collect->where($cdata)->select();
         //dump($Deliver_collect);
          // dump($collectlist);
          $this->assign('collect_list',$collectlist);
          $this->display();
          
    }
    public function  collect(){
         
        $collect=M('Collect');
        $data['group_id'] = $_GET['gid'];
        $data['state'] = 1;
        $collect_list=$collect->where($data)->field('cid,group_id,group_name,title,content,count,end_time,create_time,state')->order('cid desc')->select(); 
        $this->assign('collect_list',$collect_list); 
        //dump($collect_list);
        $this->assign('collect',$collect_list);
        $this->display('Group:collectlist');
          
    }
     public function download(){
         
     }
}